package com.clkj.sunhelp.adapter.list;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.clkj.sunhelp.R;
import com.clkj.sunhelp.bean.FundReleasePublicityItem;

import java.util.List;

/**
 * Created by Administrator on 2017/3/28.
 */

public class ListAdapterForPublicityOfFundRelease  extends BaseAdapter {


    List<FundReleasePublicityItem> mPublicityList;
    Context mContext;
    LayoutInflater mLayoutInflater;

    public ListAdapterForPublicityOfFundRelease(Context context, List<FundReleasePublicityItem> publicityList) {
        mContext = context;
        this.mPublicityList = publicityList;
        mLayoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mPublicityList.size();
    }

    @Override
    public Object getItem(int i) {
        return mPublicityList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        ViewHolder viewHolder = null;
        if (view == null) {
            view = mLayoutInflater.inflate(R.layout.list_item_publicity_fund_release, null);
            viewHolder = new ViewHolder();
            viewHolder.tvApplyPersonName = (TextView) view.findViewById(R.id.tv_apply_person_name);
            viewHolder.tvIdCardNo = (TextView) view.findViewById(R.id.tv_id_card_no);

            viewHolder.tvBaozhangPersonNum = (TextView) view.findViewById(R.id.tv_baozhang_person_num);
            viewHolder.tvBaozhangMoney = (TextView) view.findViewById(R.id.tv_baozhang_money);

            view.setTag(viewHolder);

        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        FundReleasePublicityItem publicity = mPublicityList.get(i);

        if (TextUtils.isEmpty(publicity.getApplicatname())==false)
        {
            viewHolder.tvApplyPersonName .setText(publicity.getApplicatname());
            viewHolder.tvApplyPersonName .setVisibility(View.VISIBLE);
        }else {
            viewHolder.tvApplyPersonName .setVisibility(View.GONE);
        }

        if (TextUtils.isEmpty(publicity.getHZIdCard())==false)
        {
            viewHolder.tvIdCardNo .setText(publicity.getHZIdCard());
            viewHolder.tvIdCardNo .setVisibility(View.VISIBLE);
        }else {
            viewHolder.tvIdCardNo .setVisibility(View.GONE);
        }

        /*if (TextUtils.isEmpty(publicity.getBzrknum())==false)
        {

            viewHolder.tvBaozhangPersonNum .setVisibility(View.VISIBLE);
        }else {
            viewHolder.tvBaozhangPersonNum .setVisibility(View.GONE);
        }*/

        viewHolder.tvBaozhangPersonNum .setText(String.valueOf(publicity.getBzrknum()));


        if (TextUtils.isEmpty(publicity.getXQMZ_SP_SJBTJE())==false)
        {
            viewHolder.tvBaozhangMoney .setText(publicity.getXQMZ_SP_SJBTJE());
            viewHolder.tvBaozhangMoney .setVisibility(View.VISIBLE);
        }else {
            viewHolder.tvBaozhangMoney .setVisibility(View.GONE);
        }

        return view;
    }


    static class ViewHolder {
        private TextView tvApplyPersonName;
        private TextView tvIdCardNo;
        private TextView tvBaozhangPersonNum;
        private TextView tvBaozhangMoney;





    }
}





   /*


*/